<?php
/**
 * Description:
 *
 * @author      Eden
 * @datetime    2016/12/3 13:10
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

class Lists extends ADM_Controller
{
    // 每页条数
    const PAGE_SIZE = 20;

    /**
     * 初始化
     */
    public function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $params = $this->input->get();
        $page = !empty($params['page']) && intval($params['page']) > 0 ? $params['page'] : 1;
        $offset = ($page - 1) * self::PAGE_SIZE;
        $limit = self::PAGE_SIZE;

        $this->load->model('admin/user/Index_Model', 'user');
        $lists = $this->user->getLists($params, $offset, $limit);
        if (empty($lists)) {
            $lists = array(
                'total' => 0, 'data' => array()
            );
        }

        $this->load->library('core/Page', null, 'p');
        $url = base_url('/user/lists/index');
        $page = $this->p->getPage($url, $lists['total'], self::PAGE_SIZE);

        $this->load->view('admin/user/list.html', array(
            'lists' => $lists,
            'page' => $page
        ));
    }
}
